<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/public/static/admin/css/layui.css"  media="all">
    <link rel="stylesheet" type="text/css" href="/public/web/css/style.css"/>
    <script src="/public/static/admin/layui.js"></script>

    <script src="/public/js/jquery.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<style>
    .search {
        padding: 10px 10px;
    }
    .layui-elem-quote {
        margin-bottom: 10px;
        padding: 15px;
        line-height: 22px;
        border-left: 5px solid #009688;
        border-radius: 0 2px 2px 0;
        background-color: #f2f2f2;
    }

    blockquote, body, button, dd, div, dl, dt, form, h1, h2, h3, h4, h5, h6, input, li, ol, p, pre, td, textarea, th, ul {
        margin: 0 ;
        padding: 0;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
    blockquote {
        display: block;
        -webkit-margin-before: 1em;
        -webkit-margin-after: 1em;
        -webkit-margin-start: 0px;
        -webkit-margin-end: 40px;
    }
    .layui-table-cell{width:40px;}
    .layui-layer-loading .layui-layer-content {

        width: 100% !important;
        position: relative;
        background: url(/public/images/loading-1.gif) center no-repeat !important;

    }
    .layui-layer-loading .layui-layer-content p{    position: absolute;
        left: 50%;
        top: 60%;
        margin-left: -92px;color:#fff;}
</style>
<script>
    //更改后台字段
    function admin_update(obj,table_name,table_field,table_id,id_value,encrypt){
        var new_obj = $(obj);
        layer.confirm('确定修改', function(index){
            var field_value = new_obj.prev('input').val();
            $.post('/admin/upload/edit',{'table_name':table_name,'table_field':table_field,'table_id':table_id,'id_value':id_value,'field_value':field_value},function(data){
                console.log(data)
                if(data.status == 1){
                    layer.msg(data.msg,{icon: 1});
                }else{
                    layer.msg(data.msg,{icon: 2});
                }
            },'json')
            layer.close(index);
        });
    }
    function add_t(obj,title){
        var url = $(obj).data('url');
        var index = layui.layer.open({
            title : title,
            type : 2,
            content : url,
            success : function(layero, index){
                setTimeout(function(){
                    layui.layer.tips('点击此处返回列表', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3,
                        time:3000
                    });
                },500)
            }
        });
        //改变窗口大小时，重置弹窗的高度，防止超出可视区域（如F12调出debug的操作）
        $(window).resize(function(){
            layui.layer.full(index);
        });
        layui.layer.full(index);
    }
    function table_r(tableIns) {
        if(_count==0){
            tableIns.reload({where:{}});
        }
        $(document).find(".layui-laypage-skip").children('.layui-input').val(_cur_page);
        $(document).find(".layui-laypage-btn").click();
    }
    // layer = parent.layer === undefined ? layui.layer : parent.layer,
    // layer.closeAll("iframe");
</script>
<block name="content">

    <form class="layui-form" action="" method="post">
        <div class="layui-form-item">
            <table class="layui-table" lay-size="sm" style="margin-bottom: 15px">
                <tr>
                    <td colspan="2" class="startInfo" style="text-align: center;font-size: 30px;height: 50px;color: green">开始更新数据</td>
                </tr>
                <tr>
                    <input type="hidden" id="key" value="<?php echo $key;?>">
                    <td style="width: 50%;text-align: center;font-size: 30px;height: 50px;">已生成：<span class="usercount"><?php echo $userCount;?></span> 条数据</td>
                    <td style="width: 50%;text-align: center;font-size: 30px;height: 50px;">正在生成：<span class="aa">0</span> 条数据</td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align: center;height: 300px;padding-left: 430px;">
                        <span style="font-size: 50px;display: block;width: 300px;height:300px;float: left;line-height: 300px;" class="pageNum">0</span>
                        <span style="display: block;width: 200px;height:300px;float: left;line-height: 300px;">~</span>
                        <span style="font-size: 50px;display: block;width: 300px;height:300px;float: left;line-height: 300px;" class="numll">1</span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="startInfo" style="text-align: center;height: 50px;">
                        <span class="layui-btn startGengxing" onclick="gengxing(0,1)">开始更新</span>
                        <span class="layui-btn layui-btn-warm update" style="display: none;">正在处理...</span>
                    </td>
                </tr>
            </table>
        </div>
    </form>

    <script>
       function gengxing(start,end) {
           $('.startGengxing').css('display','none');
           $('.update').css('display','');
           var usercount = $('.usercount').html();
           var key       = $('#key').val();
           $.ajax({
               url:'{:url("/index/Index/create_aa")}',
               async:true,
               dataType:'json',
               type:'POST',
               data: {'start':start,'end':end,'usercount':usercount,'key':key},
               success:function(res){
                   var dataobj = $.parseJSON(res);
                   if(dataobj.code==1){
                       $('.pageNum').html(dataobj.starty);
                       $('.aa').html(dataobj.sumNum);
                       $('.numll').html(dataobj.numll);
                       $('.usercount').html(dataobj.count);
                       gengxing(dataobj.starty,end);
                   }else{
                       $('.update').html('更新完成');
                       layer.msg(dataobj.msg,{icon: 5});
                   }
               }
           });
           return false;
       }
    </script>
</block>
